/* eslint-disable */
export function invokeAPi (methodName?: string, b?: any, c?: any, d?: any, e?:any, f?:any, g?:any, h?:any, i?:any) {
  const a = Array.prototype.slice.call(arguments)
  return window.xz_call && window.xz_call.apply(this, a)
}

export function invokeAsyncAPi<T> (methodName?: string, reportId?: any, sceneId?: any, payload?: any, d?: any, e?:any, f?:any, g?:any, h?:any, i?:any): Promise<T> {
  const a = Array.prototype.slice.call(arguments)
  return new Promise((resolve) => {
    a.push((...args: any[]) => resolve(args.length > 1 ? args : args[0]))
    window.xz_call && window.xz_call.apply(this, a)
  })
}

export function registerInformApi (apiName: any, cb: any) {
  (window.xz_register && window.xz_register(apiName, cb)) || (window[apiName] = cb)
}
export function actionReport (code: any) {
  invokeAsyncAPi('xz_substat_action', code)
}
/**
 * @param reportId {Number} 埋点id
 * @param info { Object | null } 更多信息
 * @return null
*/
export const reportInfoApi = (reportId: number, info?: any) => {
  console.log('上报-----', reportId) // #test
  if (info) {
    console.log('上报信息-----', info) // #test

    return invokeAsyncAPi('xz_submit_info_report', reportId, JSON.stringify(info))
  }
  return invokeAsyncAPi('fq_substat_action', reportId)
}
// /**
//  * @param sceneId {Number} 场景id
//  * @param reportId {Number} 埋点id
//  * @param payload {String|Number} 值
//  * @return null
// */
// export const reportInfoApi = (sceneId: any, reportId: any, payload: any) => {
//   // 参数为字符串类型时
//   let methodName = 'information_string_report'
//   // 数值类型
//   if (/^(-?\d+)(\.\d+)?$/.test(payload)) {
//     methodName = 'information_count_report'
//   }
//   return invokeAsyncAPi(methodName, reportId, sceneId, payload)
// }
